from sklearn.datasets import fetch_california_housing
import xgboost
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error as MSE

x, y = fetch_california_housing(return_X_y=True)
train_x, test_x, train_y, test_y = train_test_split(x, y, test_size=0.2)

dtrain = xgboost.DMatrix(train_x, train_y)
dtest = xgboost.DMatrix(test_x, test_y)

param = {'silent': True, 'objective':'reg:linear', "eta":0.1}
xgb = xgboost.train(param, dtrain, num_boost_round=175)
pred = xgb.predict(dtest)
print(MSE(test_y, pred))
